(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseHousekeepingFeeType: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseHousekeepingFeeTypeInfo: {
                housekeepingFeeTypes: [],
                _currentHousekeepingFeeTypeName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseHousekeepingFeeType', 'openChooseHousekeepingFeeTypeModel', function (_param) {
                $('#chooseHousekeepingFeeTypeModel').modal('show');
                $that._refreshChooseHousekeepingFeeTypeInfo();
                $that._loadAllHousekeepingFeeTypeInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllHousekeepingFeeTypeInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        shopId: vc.getCurrentCommunity().shopId,
                        name: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('/housekeepingFeeType/queryHousekeepingFeeTypes',
                    param,
                    function (json) {
                        var _housekeepingFeeTypeInfo = JSON.parse(json);
                        $that.chooseHousekeepingFeeTypeInfo.housekeepingFeeTypes = _housekeepingFeeTypeInfo.housekeepingFeeTypes;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseHousekeepingFeeType: function (_housekeepingFeeType) {
                if (_housekeepingFeeType.hasOwnProperty('name')) {
                    _housekeepingFeeType.housekeepingFeeTypeName = _housekeepingFeeType.name;
                }
                vc.emit($props.emitChooseHousekeepingFeeType, 'chooseHousekeepingFeeType', _housekeepingFeeType);
                vc.emit($props.emitLoadData, 'listHousekeepingFeeTypeData', {
                    housekeepingFeeTypeId: _housekeepingFeeType.housekeepingFeeTypeId
                });
                $('#chooseHousekeepingFeeTypeModel').modal('hide');
            },
            queryHousekeepingFeeTypes: function () {
                $that._loadAllHousekeepingFeeTypeInfo(1, 10, $that.chooseHousekeepingFeeTypeInfo._currentHousekeepingFeeTypeName);
            },
            _refreshChooseHousekeepingFeeTypeInfo: function () {
                $that.chooseHousekeepingFeeTypeInfo._currentHousekeepingFeeTypeName = "";
            }
        }

    });
})(window.vc);
